/*=========================================================================
Elite College as Engines of Upward Mobility: Evidence from Colombia's Ser Pilo Paga
Authors: Juliana Londoño-Vélez, Catherine Rodriguez, Fabio Sánchez
and Luis Esteban Álvarez-Arango

Creation date: June 6th, 2025
--------------------------------------------------------------------------
Figures A1, A2a and A2b
=========================================================================*/


use "${data}/data_RD", clear
keep if icfes_per==20142

* DENSITY
tab eligible_sisben if eligible_saber11==1
tab eligible_saber11 if eligible_sisben==1

twoway (kdensity running_saber11 if eligible_sisben==1, color(gs9)) (kdensity running_saber11 if eligible_sisben==0, color(gs0)), ///
legend(order(1 "SISBEN-eligible" 2 "SISBEN-ineligible") position(2) ring(0)) xtitle("Distance to SABER 11 cutoff") ytitle("Density") xline(0, lpattern(dash) lcolor(red))
graph export "${outcomes}/FigA1.pdf", replace 

** SABER 11
rddensity running_saber11 if eligible_sisben==1, c(0) vce(plugin) pl plot_range(-60 60) hist_range(-60 60) graph_opt(xline(0, lcolor(black) lpattern(line)) xtitle(Distance to SABER 11 cutoff) legend(off) xlab(-60(20)60) caption(Sample restricted to SISBEN-eligible individuals., size(small))) esll_opt(lcolor(gray)) cirl_opt(color(gray*0.5)) histl_opt(color(gray*0.4) barwidth(1)) nomasspoints kernel(uniform) eslr_opt(lcolor(gs3)) cirr_opt(color(gs4)) histr_opt(color(gs5) barwidth(1))
local p_value = round(`e(pv_q)', 0.001)
gr_edit .note.text.Arrpush * p-value: 0`p_value'
graph export "${outcomes}/FigA2a.pdf", replace 
	
** SISBEN III
rddensity running_sisben if eligible_saber11==1, c(0) vce(plugin) pl plot_range(-20 20) hist_range(-20 20) graph_opt(xline(0, lcolor(black) lpattern(line)) xtitle(Distance to SISBEN cutoff) legend(off) xlab(-20(10)20) caption(Sample restricted to SABER 11-eligible individuals., size(small))) esll_opt(lcolor(gray)) cirl_opt(color(gray*0.5)) histl_opt(color(gray*0.4) barwidth(0.5)) nomasspoints kernel(uniform) eslr_opt(lcolor(gs3)) cirr_opt(color(gs4)) histr_opt(color(gs5) barwidth(0.5))
local p_value = round(`e(pv_q)', 0.001)
gr_edit .note.text.Arrpush * p-value: 0`p_value'
graph export "${outcomes}/FigA2b.pdf", replace 
	
